﻿using System.Globalization;
using GC_VKMD.MusicDownloaderClient.Abstractions.Interfaces.Helpers;

namespace GC_VKMD.MusicDownloaderClient.Abstractions.Helpers
{
	public abstract class BaseApplicationConfiguration : IApplicationConfiguration
	{
		#region IApplicationConfiguration Members

		public string AppId
		{
			get { return Get("AppId"); }
			set { Set("AppId", value); }
		}

		public string Token
		{
			get { return Get("Token"); }
			set { Set("Token", value); }
		}

		public string UserId
		{
			get { return Get("UserId"); }
			set { Set("UserId", value); }
		}

		public string Folder
		{
			get { return Get("Folder"); }
			set { Set("Folder", value); }
		}

		public int AudioTracksCount
		{
			get
			{
				int result;
				int.TryParse(Get("AudioTracksCount"), out result);
				return result;
			}
			set { Set("AudioTracksCount", value.ToString(CultureInfo.InvariantCulture)); }
		}

		public virtual void ReopenConfigFile() { }

		#endregion

		#region Abstractions

		public abstract string Get(string name);

		public abstract void Set(string name, string value);

		#endregion
	}
}
